#include<iostream>
#include<chrono>
#include<thread>
#include<future>
using namespace std;

void thread1(promise<int> value)
{
	for (int i = 0; i < 5; i++)
	{
		cout<< "thread1 running... " << i <<endl;
		this_thread::sleep_for(chrono::seconds(1));
	}
	
	value.set_value(1023);
}

int main(void)
{
	promise<int> v;
	future<int> f = v.get_future();
	thread t1(thread1, move(v));
	t1.join();
	
	cout<< "result = " << f.get() << endl;
	
	return 0;
}
